<!--
<div class="alert alert-success"><span class="glyphicon glyphicon-info-sign"></span> 输入您的微信公众平台账号和密码，可以把微美风铃系统一键绑定到微信公众平台。</div>

<form action="" class="form-horizontal" role="form">
	<div class="form-group">
	    <label class="col-sm-2 control-label">公众平台账号</label>
	    <div class="col-sm-2">
			<input type="text" id="account" class="form-control" value="{$wechat.account}" datatype="*"/>
		</div>
	</div>
	<div class="form-group">
	    <label class="col-sm-2 control-label">公众平台密码</label>
	    <div class="col-sm-2">
			<input type="password" id="password" class="form-control" value="{$wechat.password}" />
		</div>
	</div>
	
	<div class="form-group">
		<div class="col-sm-offset-2 col-sm-8">
			<button type="button" class="btn btn-primary" id="btn-bind">一键绑定公众平台</button>
		</div>
	</div>
</form>

<script>
	$(function(){
		$("#btn-bind").click(function(){
			var othis = $(this);
			$.ajax({
				type:'POST',
				url:'__CONTROLLER__/bind',
				data:{
					account:$("#account").val(),
					password:$("#password").val(),
					url:$("#url").val(),
					token:$("#token").val()
				},
				dataType:'json',
				beforeSend: function(){
					othis.attr("disabled",true);
				},
				success:function(data){
					$().alertMsg({type:'info',msg:data.msg});
				},
				error:function(){
					$().alertMsg({type:'info',msg:data.msg});
				},
				complete: function(){
					othis.removeAttr("disabled");
				}
			});
		});
	});
</script>-->

<div class="alert alert-info"><span class="glyphicon glyphicon-info-sign"></span> 将下面URL和Token填入微信公共平台，绑定微网站。</div>

<form action="" class="form-horizontal" role="form">
	<div class="form-group">
	    <label class="col-sm-2 control-label">接口URL(开发者中心-配置项-服务器配置)</label>
	    <div class="col-sm-4">
			<input type="text" readonly="readonly" id="url" class="form-control" value="{$wechat.url}" datatype="*"/>
			<a href="javascript:void(0)" id="copyUrl">复制</a>
		</div>
	</div>
	<div class="form-group">
	    <label class="col-sm-2 control-label">接口Token(开发者中心-配置项-服务器配置)</label>
	    <div class="col-sm-2">
			<input type="text" id="token" readonly="readonly" class="form-control" value="{$wechat.token}" />
			<a href="javascript:void(0)" id="copyToken">复制</a>
		</div>
		<button type="submit" class="btn btn-default submit" data-loading-txt="更新中，请稍后……" data-action-callback="1" data-ajax-url="__CONTROLLER__/updateTokenPost">更新Token</button>
	</div>
	<div class="form-group">
        <label class="col-sm-2 control-label">支付目录（微信支付-开发配置-支付配置-支付授权目录）</label>
        <div class="col-sm-4">
            <input type="text" readonly="readonly" id="payUrl" class="form-control" value="{$wechat.payUrl}" datatype="*"/>
            <a href="javascript:void(0)" id="copyPayUrl">复制</a>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">业务域名（设置-公众号设置-功能设置-业务域名）</label>
        <div class="col-sm-4">
            <input type="text" readonly="readonly" id="bussinessDomain" class="form-control" value="{$wechat.bussinessDomain}" datatype="*"/>
            <a href="javascript:void(0)" id="copyBussinessDomain">复制</a>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">JS接口安全域名（设置-公众号设置-功能设置-JS接口安全域名）</label>
        <div class="col-sm-4">
            <input type="text" readonly="readonly" id="jsSafeDomain" class="form-control" value="{$wechat.jsSafeDomain}" datatype="*"/>
            <a href="javascript:void(0)" id="copyJsSafeDomain">复制</a>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">授权回调页面域名（开发者中心-配置项-接口权限表-网页服务-网页账号-修改）</label>
        <div class="col-sm-4">
            <input type="text" readonly="readonly" id="redirectDomain" class="form-control" value="{$wechat.redirectDomain}" datatype="*"/>
            <a href="javascript:void(0)" id="copyRedirectDomain">复制</a>
        </div>
    </div>
</form>

<form action="" class="form-horizontal" role="form">
	
	<!--<div class="form-group">
	    <label class="col-sm-2 control-label">微信号</label>
	    <div class="col-sm-4">
	    	<input type="text" class="form-control" name="name" value="{$wechat.name}" datatype="*" />
	    </div>
	</div>-->
	
	<div class="form-group">
	    <label class="col-sm-2 control-label">开发者AppId</label>
	    <div class="col-sm-4">
	    	<input type="text" class="form-control" name="appid" value="{$wechat.appid}" <notempty name='wechat.appid'>readonly="readonly"</notempty> />
	    	<span class="label label-danger">注意：请核实AppId是否正确，一经填写无法修改！</span>
	    </div>
	</div>
	
	<div class="form-group">
	    <label class="col-sm-2 control-label">开发者AppSecret</label>
	    <div class="col-sm-4">
	    	<input type="text" class="form-control" name="appsecret" value="{$wechat.appsecret}" />
	    </div>
	</div>
	
	<div class="form-group">
	    <label class="col-sm-2 control-label">模板消息类型</label>
	    <div class="col-sm-4">
	    	<select class="form-control" name="templateType">
	    		{$templateTypeOptions}
	    	</select>
	    </div>
	</div>
	
	<div class="form-group">
	    <label class="col-sm-2 control-label">模板消息模板id</label>
	    <div class="col-sm-4">
	    	<input type="text" class="form-control" name="templateid" value="{$wechat.templateid}" />
	    </div>
	</div>
	
	<div class="form-group">
		<div class="col-sm-offset-2 col-sm-8">
			<input type="hidden" class="form-control" name="id" value="{$wechat.id}" />
			<button type="submit" class="btn btn-primary submit" data-loading-txt="更新中，请稍后……" data-ajax-url="__CONTROLLER__/indexPost">保存更改</button>
		</div>
	</div>
</form>
<style>
	form:nth-of-type(1){
		border-bottom:1px solid #ccc;
		margin-bottom:20px;
	}
</style>
<script type="text/javascript" src="__PUBLIC__/Style/Common/js/ZeroClipboard.js"></script>
<script>
	function actionCallback( data) {
		$("#token").val( data.token );
		$().copyPaste({
			text: $("#token").val(),
			id: "copyToken"
		});
	}
	$().copyPaste({
		text: $("#url").val(),
		id: "copyUrl"
	});
	$().copyPaste({
		text: $("#token").val(),
		id: "copyToken"
	});
	
	
	$().copyPaste({
        text: $("#payUrl").val(),
        id: "copyPayUrl"
    });
    $().copyPaste({
        text: $("#jsSafeDomain").val(),
        id: "copyJsSafeDomain"
    });
    $().copyPaste({
        text: $("#redirectDomain").val(),
        id: "copyRedirectDomain"
    });
    $().copyPaste({
        text: $("#bussinessDomain").val(),
        id: "copyBussinessDomain"
    });
</script>